package cn.doitedu.day04

import org.apache.spark.{SparkConf, SparkContext}

object T04_CollectDemo {

  def main(args: Array[String]): Unit = {

    //1.创建SparkConf
    val conf = new SparkConf().setAppName("WordCount")
      .setMaster("local[4]") //如果提交到集群中运行，setMaster必须注释掉

    //2.创建SparkContext
    val sc = new SparkContext(conf)

    val lines = sc.textFile("data/shop.txt")

    val arr: Array[String] = lines.collect()
    val array: Array[Array[String]] = sc.runJob(lines, (it: Iterator[String]) => it.toArray)
    val res = Array.concat(array: _*)

    println(res.toBuffer)
  }

}
